<?php

namespace application\Controller;

use application\Components\BaseController;
use application\Comm\Request;
use library\Core\Config;
use library\Core\Db\CDbCriteria;
use application\Comm\Func;
use application\Module\ShowHome;
use application\Module\Adimage;
use application\Model\ShowHomeModel;

class ShowhomeController extends BaseController
{
    /**
     * @throws \application\Components\CException
     * 列表
     */
    public function actionIndex()
    {
    	
		$showhomemodule = new ShowHome();
		$select = [
			'id',
			'category_id',
			'style_id',
			'acreage',
			'user_name',
			'title',
			'description',
			'thumb',
			'src',
			'create_time',
		];
		$showhomedata = $showhomemodule->getList($select);
		
		//热门装修案例
		$hotdata = $showhomemodule->getHot();
		
		//轮播
		$adminimg = new Adimage();
		$carousel = $adminimg ->getList(25,['id','name','src']);
		
		//设计师轮播图
		$designer = $adminimg ->getList(26,['id','name','description','src']);
		$designer = $designer ? $designer[0] : ['name'=>'','src'=>'','description'=>''];
        $this->render('showhome/index', [
        	'carousel' => $carousel,
        	'designer' => $designer,
            'showhomedata' => $showhomedata['data'],
        	'page' => $showhomedata['page'],
        	'hotdata' => $hotdata,
        ]);
    }

    /**
     * @param $id
     * 详情
     */
    public function actionView($id)
    {
    	$showhomemodule = new ShowHome();
    	//详情
    	$showhomedata = $showhomemodule->getView($id);
    	//最新发布
    	$select = [
			'id',
			'title',
			'src'
    	];
     	$new = $showhomemodule->getHot(1,$select,5);
        $this->render('showhome/view', [
			'showhomedata' => $showhomedata,
        	'new' => $new,
        ]);
    }


}
